#include "modelmanager.h"

ModelManager::ModelManager()
{
	
}

Model* ModelManager::load(std::string file)
{
	this->modeles[file] = new Model(file);
	return modeles[file];
}

Model* ModelManager::get(std::string file)
{
	Model* mdl = modeles[file];
	
	if(mdl == NULL)
	{
		return this->load(file);
	}
	else
	{
		return mdl;
	}
}

void ModelManager::unload(std::string file)
{
	delete modeles[file];
	modeles[file] = NULL;
}

ModelManager::~ModelManager()
{
	for(std::map<std::string, Model*>::iterator it = modeles.begin(); it != modeles.end(); ++it)
	{
		this->unload(it->first);
	}
}